package PloyArray;

public class Main {
    public static void main(String[] args) {
        Person[] persons = new Person[5];
        persons[0] = new Person("John", 22);
        persons[1] = new Student("Mike", 18, 99.5);
        persons[2] = new Student("Jane", 21, 87.1);
        persons[3] = new Teacher("King", 32, 10000);
        persons[4] = new Teacher("Henry", 45, 18000);
        for (Person i : persons) {
            System.out.println(i.say());
            if(i instanceof Teacher){
                Teacher t = (Teacher) i;
                t.teaching();
            }
            else if(i instanceof Student){
                Student s = (Student) i;
                s.studying();
            }
        }
    }
}
